package ace.module.product.core.impl.dao.repository;


import ace.cmp.spring.data.jdbc.querydsl.core.repository.QuerydslJdbcBaseRepository;
import ace.module.product.core.impl.constant.ProductCoreConstant;
import ace.module.product.core.impl.dao.entity.PmsProductCategoryRelation;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.stereotype.Repository;

/**
 * 商品与分类关系 repository.
 *
 * @author Caspar
 */
@DS(ProductCoreConstant.DEFAULT_DATA_SOURCE_NAME)
@Repository
public interface PmsProductCategoryRelationRepository extends QuerydslJdbcBaseRepository<PmsProductCategoryRelation,Long> {

  boolean existsByPmsAppIdAndProductIdAndCategoryIdAndCategoryTypeAndDeleteFlag(Long pmsAppId, Long productId, Long categoryId, Integer categoryType, Long deleteFlag);

  PmsProductCategoryRelation findByPmsAppIdAndProductIdAndCategoryIdAndCategoryTypeAndDeleteFlag(Long pmsAppId, Long productId, Long categoryId, Integer categoryType, Long deleteFlag);


  PmsProductCategoryRelation findByPmsAppIdAndProductIdAndCategoryTypeKeyAndCategoryTypeAndDeleteFlag(
      Long pmsAppId,
      Long productId,
      Long categoryKey,
      Integer categoryType,
      Long deleteFlag
  );
}